//
//  MXHomeWashCollectionViewCell.m
//  MXの衣柜
//
//  Created by 马霄 on 15/8/11.
//  Copyright (c) 2015年 霄 马. All rights reserved.
//

#import "MXHomeWashCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface MXHomeWashCollectionViewCell ()
@property (nonatomic, retain) UIImageView *mainImageView;

@property (nonatomic, retain) UILabel *kindLabel;

@end
@implementation MXHomeWashCollectionViewCell
- (void)dealloc
{
    [_washModelS release];
    [_mainImageView release];
    [_kindLabel release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.mainImageView = [[[UIImageView alloc]init] autorelease];
        self.mainImageView.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:self.mainImageView];
        
        self.kindLabel = [[[UILabel alloc] init] autorelease];
        self.kindLabel.backgroundColor = [UIColor whiteColor];
        self.kindLabel.textAlignment = NSTextAlignmentCenter;
        [self.kindLabel setTextColor:[UIColor blueColor]];
        self.kindLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.kindLabel];
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat mainImageViewX = self.contentView.frame.size.width / 2 - WIDTH / 375 * 40;
    CGFloat mainImageViewY = HEIGHT / 667 * 30;
    CGFloat mainImageViewW = WIDTH / 375 * 80;
    CGFloat mainImageViewH = HEIGHT / 667 * 80;
    self.mainImageView.frame = CGRectMake(mainImageViewX, mainImageViewY, mainImageViewW, mainImageViewH);
    self.mainImageView.layer.cornerRadius = mainImageViewH / 2;
    self.mainImageView.layer.masksToBounds = YES;
    
    CGFloat kindLabelX = mainImageViewX - WIDTHPRO * 20;
    CGFloat kindLabelY = mainImageViewY + mainImageViewH;
    CGFloat kindLabelW = mainImageViewW + WIDTHPRO * 40;
    CGFloat kindLabelH = HEIGHT / 667 * 30;
    self.kindLabel.frame = CGRectMake(kindLabelX, kindLabelY, kindLabelW, kindLabelH);
}
-(void)GetWashInfo:(MXHomeWashModel *)model
{
    if (_washModelS != model) {
        [_washModelS release];
        _washModelS = [model retain];
    }
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.kind_icon] placeholderImage:[UIImage imageNamed:@"plaseholder"]];
    
    self.kindLabel.text = model.kind_name;
}
@end
